package com.hoshiicloud.shxping.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hoshiicloud.shxping.dto.ESSpuDTO;
import com.hoshiicloud.shxping.feign.hystrix.HystrixElasticSearchFeignFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author yangcheng
 * @version 1.0
 * @title: IElasticSearchFeignService
 * @description: ES微服务FeignClient
 * @date 2019/9/12 10:31
 * @mail maiboyc@163.com
 */
@FeignClient(name = "hoshiicloud-elasticsearch", fallback = HystrixElasticSearchFeignFallback.class)
public interface IElasticSearchFeignService {

    /**
     * 查询商品列表
     * @param storeId   店铺ID
     * @param pageNum   页码
     * @param pageSize  每页记录数
     * @return Page<ESSpuDTO>
     */
    @RequestMapping(value = "/spu/search/list", method = RequestMethod.GET)
    Page<ESSpuDTO> list(@RequestParam("storeId") Long storeId,
                        @RequestParam("pageNum") Integer pageNum,
                        @RequestParam("pageSize") Integer pageSize);

    /**
     * 简单搜索
     * @param keyword   关键字
     * @param pageNum   页码
     * @param pageSize  每页记录数
     * @return Page<ESSpuDTO>
     */
    @RequestMapping(value = "/spu/search/simple", method = RequestMethod.GET)
    Page<ESSpuDTO> search(@RequestParam("keyword") String keyword,
                            @RequestParam("storeId") Long storeId,
                            @RequestParam("pageNum") Integer pageNum,
                            @RequestParam("pageSize") Integer pageSize);
}
